package com.sgb.contract.view.ui.contract;

import androidx.lifecycle.MutableLiveData;

import com.sgb.contract.api.AbstractCallBack;
import com.sgb.contract.api.ContractNet;
import com.sgb.contract.base.viewmodel.BaseViewModel;
import com.sgb.contract.model.ContractCategoryBean;
import com.swgk.core.base.model.entity.BaseEntity;

import java.util.List;

import retrofit2.Call;

/**
 * 描述：合同（个人中心、企业网站）
 *
 * @author qiangHeNoo
 * <p>
 * 时间：2021.11.04
 */
public class ContractModel extends BaseViewModel {

    public MutableLiveData<List<ContractCategoryBean>> contractCategory = new MutableLiveData<>();

    /**
     * 获取合同分类
     */
    public void getContractCategory() {
        showLoading();
        ContractNet.getInstance().getContractApi().contractCategory().enqueue(new AbstractCallBack<BaseEntity<List<ContractCategoryBean>>>() {
            @Override
            public void onSuccess(BaseEntity<List<ContractCategoryBean>> data) {
                if (null != data.getData() && data.getData().size() != 0) {
                    contractCategory.postValue(data.getData());
                } else {
                    contractCategory.postValue(null);
                }
            }

            @Override
            public void onFailure(Call call, Throwable t) {
                contractCategory.postValue(null);
            }
        });
    }
}
